import axios from "axios";
import { message } from "ant-design-vue";
const Axios = axios.create({
  baseURL: "http://localhost:8080/Stash",
  timeout: 500000,
  responseEncoding: "utf8",
  // header: {
  //     "Content-Type": "application/xml"
  //     // "Content-Type": "application/x-www-form-urlencoded"
  //     // "Content-Type"为"application/x-www-form-urlencoded"
  // }
});
Axios.interceptors.request.use((config) => {
  if (config.data) {
    if (config.data.value) {
      config.data = config.data.value;
    } else {
      config.data = config.data;
    }
  }

  return config;
});
Axios.interceptors.response.use(
  (response) => {
    const res = response.data;

    return res;
  },
  (error) => {
    let list = {
      message: error.message,
      code: 201,
    };
    message.error(error.message);
    return list;
  }
);

export default Axios;
